package com.woniuxy01;

import java.util.Objects;

/**
 * @author 作者
 * @create 2025-06-03 10:55
 */
public class Student {
    private String sid;
    private String name;
    private int age;

    public Student() {
    }

    public Student(String sid, String name, int age) {
        this.sid = sid;
        this.name = name;
        this.age = age;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "sid='" + sid + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

//    @Override
//    public boolean equals(Object o) {
//        if (!(o instanceof Student student)) return false;
//        return age == student.age && Objects.equals(sid, student.sid) && Objects.equals(name, student.name);
//    }

//    @Override
//    public boolean equals(Object o) {
//        if (o == null || getClass() != o.getClass()) return false;
//        Student student = (Student) o;
//        return age == student.age && Objects.equals(sid, student.sid) && Objects.equals(name, student.name);
//    }


    @Override
    public boolean equals(Object obj) {
//       当前对象的属性值和参数的属性值比较
        if (obj instanceof Student) {
            Student other = (Student) obj;
            return this.sid.equals(other.sid) &&
                    this.name.equals(other.name) &&
                    this.age == other.age;
        } else {
            return false;
        }
    }
}
